// 2712. 使所有字符相等的最小成本
// AC: https://leetcode.cn/problems/minimum-cost-to-make-all-characters-equal/submissions/616238059/

class Solution {
public:
    typedef long long ll;
    long long minimumCost(string s) {
        int n=s.size();
        ll ans=0;
        for(int i=1;i<n;++i){
            if(s[i]!=s[i-1])
                ans+=min(i,n-i);
        }
        return ans;
    }
};